var checkObject = function(){
    return {
            VariousTime : function(){
                // Vue实例化
                var doit = new Vue({
                        el:'#choseTime1',
                        data: {
                            value1: '',
                            valDayS :'',
                            valDayE :''
                        },
                        methods: {
                            change(a) {
                                    /*$(".valDayS").css("opacity",1);
                                     $(".valDayE").css("opacity",1);
                                     $(".timeS").css("opacity",0);
                                     $(".timeE").css("opacity",0);
                                     $(".tjTimeS").css("opacity",0);
                                     $(".tjTimeE").css("opacity",0);
                                     $(".valYearS").css("opacity",0);
                                     $(".valYearE").css("opacity",0);*/
                                        var date=new Date(a);
                                        var month = date.getMonth() + 1;
                                        var day = date.getDate();
                                        month = (month.toString().length == 1) ? ("0" + month) : month;
                                        day = (day.toString().length == 1) ? ("0" + day) : day;
                                        var nowTime = date.getFullYear()+"-"+month+"-"+day;
                                        $(".tjTimeS").html(nowTime);
                                        $(".tjTimeE").html(nowTime);
                                        $(".timeModule").show();
                                        $(".more-chose").hide();
                                }
                        },
                        computed: {

                        },
                    });
                var doit1 = new Vue({
                    el:'#choseTime2',
                    data: {
                        value3: '',
                        valS:'',
                        valE:'',
                    },
                    methods: {
                        change(b) {
                                 /*$(".timeS").css("opacity",1);
                                 $(".timeE").css("opacity",1);
                                 $(".tjTimeS").css("opacity",0);
                                 $(".tjTimeE").css("opacity",0);
                                 $(".valDayS").css("opacity",0);
                                 $(".valDayE").css("opacity",0);
                                 $(".valYearS").css("opacity",0);
                                 $(".valYearE").css("opacity",0);*/
                                 var firstTime = 1;
                                 var lastTime = 5;
                                    var date=new Date(b);
                                    console.log(date);
                                    var oneday = 1000 * 60 * 60 * 24;
                                    var begindate = new Date(date - oneday*firstTime);
                                    var month = begindate.getMonth() + 1;
                                    var day = begindate.getDate();
                                    month = (month.toString().length == 1) ? ("0" + month) : month;
                                    day = (day.toString().length == 1) ? ("0" + day) : day;
                                    // 前一天
                                    var beforeTime = begindate.getFullYear()+"-"+month+"-"+day;
                                    // 后一天
                                    var dayTime=lastTime*24*60*60*1000; //参数天数的时间戳
                                    var nowTime=new Date(date).getTime(); //当天的时间戳
                                    var begindate1 = new Date(nowTime+dayTime); //把两个时间戳转换成普通时间
                                    var month1 = begindate1.getMonth() + 1;
                                    var day1 = begindate1.getDate();
                                    month1 = (month1.toString().length == 1) ? ("0" + month1) : month1;
                                    day1 = (day1.toString().length == 1) ? ("0" + day1) : day1;
                                    var afterTime = begindate1.getFullYear()+"-"+month1+"-"+day1;
                                    $(".tjTimeS").html(beforeTime);
                                    $(".tjTimeE").html(afterTime);
                                    $(".timeModule").show();
                                    $(".more-chose").hide();
                            }
                    },
                    computed: {

                    },
                });
                var doit2 = new Vue({
                    el:'#choseTime3',
                    data: {
                        value4: '',
                        valYearS:'',
                        valYearE:''
                    },
                    methods: {
                        change(c) {
                                /*$(".valYearS").css("opacity",1);
                                 $(".valYearE").css("opacity",1);
                                 $(".timeS").css("opacity",0);
                                 $(".timeE").css("opacity",0);
                                 $(".tjTimeS").css("opacity",0);
                                 $(".tjTimeE").css("opacity",0);
                                 $(".valDayS").css("opacity",0);
                                 $(".valDayE").css("opacity",0);*/
                                /* var  date = new Date(c);
                                    var year = date.getFullYear(c);
                                     var month = date.getMonth(c) + 1;
                                     var day = date.getDate()-1;
                                    var lastdate = year + '-' + month + '-' + day.getDate();
                                    console.log(lastdate);*/
                                    console.log(c);
                                    var date=new Date(c);
                                    var month = date.getMonth() + 1;
                                    var day = date.getDate();
                                    month = (month.toString().length == 1) ? ("0" + month) : month;
                                    day = (day.toString().length == 1) ? ("0" + day) : day;
                                    var nowTime = date.getFullYear()+"-"+month+"-"+day;
                                   var myYear = date.getFullYear();
                                   var mymonTh = date.getMonth()+1;
                                    //构造一个日期对象：
                                    var daycount = new Date(myYear,mymonTh,0);
                                    //获取天数：
                                    // var daycount = day.getDate();
                                    var month1 = daycount.getMonth() + 1;
                                    var day1 = daycount.getDate();
                                    month1 = (month1.toString().length == 1) ? ("0" + month1) : month1;
                                    day1 = (day1.toString().length == 1) ? ("0" + day1) : day1;
                                    afterTime = date.getFullYear()+"-"+month1+"-"+day1;
                                    $(".tjTimeS").html(nowTime);
                                    $(".tjTimeE").html(afterTime);
                                    $(".timeModule").show();
                                    $(".more-chose").hide();
                            }
                    },
                    computed: {

                        }

                });
            }
        }
    };
var VariousFun = new checkObject();

$(function () {
    // 配置路径
    var pageUrl = config.urlAnaConfig.testPath;
    // 获取Cookie
    function getCookie(name){
        var strcookie = document.cookie;//获取cookie字符串
        var arrcookie = strcookie.split("; ");//分割
    //       console.log(arrcookie);
        //遍历匹配
        for ( var i = 0; i < arrcookie.length; i++) {
            var arr = arrcookie[i].split("=");
                if (arr[0] ==name){
                    return arr[1];
                }
        }
        return "";
    }
    var name = "tokenval";
    // tiken值
    var cookie_value = getCookie(name);
    console.log(cookie_value);
    var name1 = "userName";
    // 用户名值
    var cookie_value1 = getCookie(name1);
    $(".UserTips span").html(cookie_value1);



    // 导航固定
    var pageHeight = $(window).height();
    $(".main-left ul").css({
        "height": pageHeight-40,
        "overflow-x":"hidden"
    });
    $(window).resize(function() {
      var pageHeight = $(window).height();
        $(".main-left ul").css({
            "height": pageHeight-40,
            "overflow-x":"hidden"
        });
    });


    // 左侧导航展开收缩
    $(".main-left .custom").on("click",function () {
        $(this).next().slideToggle();
        $(this).find(".off-on").toggleClass("off-on1");
    });
/*    $(".main-left ul .liList .yijiNav").on("click",function () {
        $(".main-left ul li .custom").removeClass("current");
        $(this).addClass("current");
        $(".main-left ul .liList .yijiNav").next("ol").hide();
        $(this).next("ol").show();
    });*/
/*    $(".main-left ul .liList .erjiNav").on("click",function () {
        $(".main-left ul .liList .erjiNav").next("ol").hide();
        $(this).next("ol").show();
    });*/

/*// 固定选择区域
    var contentLeft = $(".content-main").offset().left;
    $(".main-right .condition-choose form").css("margin-left",contentLeft);*/

    // $(".condition-choose").css("width",$(".main-right").width());
    // 左侧导航展开收缩
    $(".main-left .zhedie").on("click",function () {
        var opt = $(this).attr("opt");
        if (opt==0){
            $(this).attr('opt','1');
            $(".main-left-nav").animate({"width":"55px"});
            $(".main-left ul li span").css({
                "margin-left":18,
                "margin-right":17
            });
            $(".zhedie img").attr("src","img/zhedie1.png");
            $(this).addClass("zhedie1");
            $(".main-right").animate({"padding-left":"55px"});
            $(".condition-choose").animate({"padding-left":"55px"});
            $(".liList .firstOl").hide();
            $(".liList .yijiNav").css("background-color","#e5e5e5");
            /*$(".business .liList .yijiNav").css("background-color","#00328c");
            $(".business .liList .yijiNav span").eq(0).css({
                "background":"url(img/icon_222.png) no-repeat",
                "background-size":"contain"
            });
            $(".details .liList .yijiNav").css("background-color","#00328c");
            $(".details .liList .yijiNav span").eq(0).css({
                "background":"url(img/icon_333.png) no-repeat",
                "background-size":"contain"
            });
            $(".activity .liList .yijiNav").css("background-color","#00328c");
            $(".activity .liList .yijiNav span").eq(0).css({
                "background":"url(img/icon_444.png) no-repeat",
                "background-size":"contain"
            });*/

        } else if (opt==1){
            $(this).attr('opt','0');
            $(".main-left-nav").animate({"width":"250px"});
            $(".main-left ul li span").css({
                "margin-left":25,
                "margin-right":10
            });
            $(".zhedie img").attr("src","img/zhedie.png");
            $(this).addClass("zhedie1");
            $(".main-right").animate({"padding-left":"250px"});
            $(".condition-choose").animate({"padding-left":"250px"});
            $(".liList .firstOl").show();
            $(".liList .yijiNav").css("background-color","#fff");
            /*$(".business .liList .yijiNav").css("background-color","#edeff3");
            $(".business .liList .yijiNav span").eq(0).css({
                "background":"url(img/icon_22.png) no-repeat",
                "background-size":"contain"
            });
            $(".details .liList .yijiNav").css("background-color","#edeff3");
            $(".details .liList .yijiNav span").eq(0).css({
                "background":"url(img/icon_33.png) no-repeat",
                "background-size":"contain"
            });
            $(".activity .liList .yijiNav").css("background-color","#edeff3");
            $(".activity .liList .yijiNav span").eq(0).css({
                "background":"url(img/icon_44.png) no-repeat",
                "background-size":"contain"
            });*/
        }

    });
    $(".main-left-nav ul .liList .custom").hover(function () {
            if($(".zhedie").attr("opt")==1){
                $(".zhedie").attr('opt','0');
                $(".main-left-nav").animate({"width":"250px"});
                $(".main-left ul li span").css({
                    "margin-left":25,
                    "margin-right":10
                });
                // $(".zhedie img").attr("src","img/zhedie.png");
                $(this).addClass("zhedie1");
                $(".main-right").animate({"padding-left":"250px"});
                $(".condition-choose").animate({"padding-left":"250px"});
                $(".liList .firstOl").show();
                $(".liList .yijiNav").css("background-color","#fff");
                /*$(".business .liList .yijiNav").css("background-color","#edeff3");
                $(".business .liList .yijiNav span").eq(0).css({
                    "background":"url(img/icon_22.png) no-repeat",
                    "background-size":"contain"
                });
                $(".details .liList .yijiNav").css("background-color","#edeff3");
                $(".details .liList .yijiNav span").eq(0).css({
                    "background":"url(img/icon_33.png) no-repeat",
                    "background-size":"contain"
                });
                $(".activity .liList .yijiNav").css("background-color","#edeff3");
                $(".activity .liList .yijiNav span").eq(0).css({
                    "background":"url(img/icon_44.png) no-repeat",
                    "background-size":"contain"
                });*/
            }
    });
    // 选择栏收缩
    var yureOrFalse = true;
    $(".eye-icon").on("click",function () {
        var conditionHeight = $(".condition-choose").height();
        if(yureOrFalse){
            $(".condition-choose").animate({
                "top":-conditionHeight
            });
            $(".main-body").animate({
                "padding-top":106-conditionHeight
            });
            $("#activity3 .main-body").animate({
                "padding-top":170-conditionHeight
            });
            $(".eye-icon span").css({
                "background":"url(img/eye_icon_2.png) no-repeat",
                "background-size":"contain"
            });
            $(this).parent("li").css({
                "background-color":"#00328c"
            });
            yureOrFalse = false;
        }else if(!yureOrFalse){
            $(".condition-choose").animate({
                "top":0
            });
            $(".main-body").animate({
                "padding-top":106
            });
            $("#activity3 .main-body").animate({
                "padding-top":170
            });
           $(".eye-icon span").css({
                "background":"url(img/eye_icon_1.png) no-repeat",
                "background-size":"contain"
            });
            $(this).parent("li").css({
                "background-color":"#fff"
            });
            yureOrFalse = true;
        }


    });
    $(window).scroll(function (){
        var st = $(this).scrollTop();
        $(".condition-choose").css("margin-top",st+40)
    });



    // selectjs
    $(".public-select1 input").on("click",function () {
        $(this).next("ul").slideToggle();
        var opt = $(this).attr("opt");
        if (opt==0){
            $(this).attr('opt','1');
            $(this).nextAll("span").addClass("on-off-select1");
            $(this).nextAll("span").removeClass("on-off-select2");
        }else if(opt==1){
            $(this).attr('opt','0');
            $(this).nextAll("span").removeClass("on-off-select1");
            $(this).nextAll("span").addClass("on-off-select2");
        }
    });
    

    $(".public-select1 ul").on("click",'li',nextFn);
        function nextFn () {

        $(this).parent("ul").prev("input").val()=='';
        var choseData = $(this).html();
        $(this).parent("ul").prev("input").val(choseData);
        //alert(choseData)
        $(this).parent("ul").hide();
        $(this).parent("ul").prev("input").attr('opt','0');
        $(this).parent("ul").nextAll("span").removeClass("on-off-select1");
        $(this).parent("ul").nextAll("span").addClass("on-off-select2");
    };
    $(document).click(function(){
        $(".public-select1 ul").hide();
        $(".public-select1 input").attr('opt','0');
        $(".public-select1 span").removeClass("on-off-select1");
        $(".public-select1 span").addClass("on-off-select2");
    });
    $(".public-select1").click(function(event){
        event.stopPropagation();
    });
    // selectjs

    // selectjs more
    $(".public-select-more input").on("click",function () {
        $(this).next(".more-chose").slideToggle();
        var opt = $(this).attr("opt");
        if (opt==0){
            $(this).attr('opt','1');
            $(this).nextAll("span").addClass("on-off-select1");
            $(this).nextAll("span").removeClass("on-off-select2");
        }else if(opt==1){
            $(this).attr('opt','0');
            $(this).nextAll("span").removeClass("on-off-select1");
            $(this).nextAll("span").addClass("on-off-select2");
        }
    });
    $(".public-select-more ul li").on("click",function () {
        /*$(this).parent("ul").prev("input").val()=='';
        var choseData = $(this).html();
        $(this).parent("ul").prev("input").val(choseData);*/
        $(this).parents(".more-chose").hide();
        $(this).parent("ul").prev("input").attr('opt','0');
        $(this).parent("ul").nextAll("span").removeClass("on-off-select1");
        $(this).parent("ul").nextAll("span").addClass("on-off-select2");
    });
    $(document).click(function(){
        $(".public-select-more .more-chose").hide();
        $(".public-select-more input").attr('opt','0');
        $(".public-select-more span").removeClass("on-off-select1");
        $(".public-select-more span").addClass("on-off-select2");
        $(".public-select-more ol").hide();
        $(this).css("background-color","#fff");
    });
    $(".public-select-more").click(function(event){
        event.stopPropagation();
    });
    $(".public-select-more ul li").hover(function () {
        $(this).css("background-color","#e6f7ff");
        $(".public-select-more ol").hide();
    },function(){
        $(this).css("background-color","#fff");
    });
    $(".zidingyi").hover(function () {
        $(this).css("background-color","#e6f7ff");
        $(".public-select-more ol").show();
    },function(){
        $(this).css("background-color","#fff");
    });
    // 重置按钮
    $(".reset-btn").on("click",function () {
        $(".timeModule").hide();
    });
  /*  var Parent= function () {

    };
    Parent.prototype.process = function(){
        alert('parent method');
    };
    var childVar = new Parent();*/


    // 1 7 30
        $(".fixedTime").on("click",function () {
                var choesDay = $(this).attr("time-data");
                var d = new Date();
                var oneday = 1000 * 60 * 60 * 24;
                var begindate = new Date(d - oneday*choesDay);
                var day = begindate.getDate();
                var dayD = (day.toString().length == 1) ? ("0" + day) : day;
                var dayE = (d.getDate().toString().length == 1) ? ("0" + d.getDate()) : d.getDate();
                var month = (begindate.getMonth()+1);
                var monthD = (month.toString().length == 1) ? ("0" + month) : month;
                var monthE = ((d.getMonth()+1).toString().length == 1) ? ("0" + (d.getMonth()+1)) : (d.getMonth()+1);
                var nowTime = d.getFullYear()+"-"+monthE+"-"+dayE;
                var beforeTime = begindate.getFullYear()+"-"+monthD+"-"+dayD;
                $(".tjTimeS").html(beforeTime);
                $(".tjTimeE").html(nowTime);
                $(".timeModule").show();
        });
//    个人信息
    $(".userIa").on("click",function () {
        $("#userXinxi").show();
    })
    $("#userXinxi .close").on("click",function () {
        $(this).parent().hide();
    });
//    个人信息
//    管理
    $(".userIa1").on("click",function () {
        $("#userXinxiGL").show();
    });

    $(".userXinxi").hover(function () {
        $(".userXinxi").show();
    },function () {
        $(".userXinxi").hide();
    });
    $(".information").hover(function () {
        $(".userXinxi").show();
    },function () {
        $(".userXinxi").hide();
    });
    $("#userXinxiGL .close").on("click",function () {
        $(this).parent().hide();
    });
    $(document).click(function(){
    $("#userXinxiGL").hide();
    });
    $(".userIa1").click(function(event){
        event.stopPropagation();
    });

    $(".application").click(function (e) {
        var event=e||event;
        event.preventDefault();
    });

    // 图形table切换
    $(".main1-con-qiehuan .xuanxiang").on("click",function () {
        $(".main1-con-qiehuan .main1-tab-left").removeClass("current");
        $(this).find(".main1-tab-left").addClass("current");
        if ($(".main1-con-tab1 .main1-tab-left").hasClass("current")){
            $(".tu1").css({
                "opacity":"1",
                "z-index":"10"
            });
            $(".tu2").css({
                "opacity":"0",
                "z-index":"9"
            });
        }else if($(".main1-con-tab2 .main1-tab-left").hasClass("current")){
            $(".tu1").css({
                "opacity":"0",
                "z-index":"9"
            });
            $(".tu2").css({
                "opacity":"1",
                "z-index":"10"
            });
        }
    });
    $(".main1-con-qiehuan .xuanxiang1").on("click",function () {
        $(".main1-con-qiehuan .xuanxiang1").removeClass("current");
        $(this).addClass("current");
        if ($(".module-04 .main1-con-tab1").hasClass("current")){

            $(".tubiao3").css({
                "opacity":"1",
                "z-index":"10"
            });
            $(".tubiao4").css({
                "opacity":"0",
                "z-index":"9"
            });
            $(".tubiao5").css({
                "opacity":"0",
                "z-index":"9"
            });
        }else if($(".module-04 .main1-con-tab2").hasClass("current")){
            $(".tubiao3").css({
                "opacity":"0",
                "z-index":"9"
            });
            $(".tubiao4").css({
                "opacity":"1",
                "z-index":"10"
            });
            $(".tubiao5").css({
                "opacity":"0",
                "z-index":"9"
            });
        }else if($(".module-04 .main1-con-tab3").hasClass("current")){
            $(".tubiao3").css({
                "opacity":"0",
                "z-index":"9"
            });
            $(".tubiao4").css({
                "opacity":"0",
                "z-index":"9"
            });
            $(".tubiao5").css({
                "opacity":"1",
                "z-index":"10"
            });
        }
    });
    // 图形table切换

/*    var contentRigthH = $(".content-rigth ul").height();
    $(".content-rigth").css("height",contentRigthH);*/
    // 登出接口调用
    $(".logout").on("click",function () {
        // console.log('登出');
        console.log(cookie_value);
        $.ajax({
                url:pageUrl+'/api/login/logout',
                type: 'POST',
                dataType: 'json',
                headers: {
                    Authorization: 'Bearer '+cookie_value
                },
                success: function (json) {
                    alert('退出成功');
                    window.location.href="login.html";
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.log('令牌已被列入黑名单');
                    window.location.href="login.html";
                    var errorTips = XMLHttpRequest.responseJSON.msg;
                    // 状态码
                    console.log(errorTips);
                }

            });
            // 图表
        });


    // 提示弹框
    $(".layer1 .close1").on("click",function () {
        $(".layer1").hide();
    });
    $(document).click(function(){
    $(".layer1").hide();
    });
    $(".layer1 .main").click(function(event){
        event.stopPropagation();
    });
        //        日历插件
    /*    var newDay=new Date();*/
   /* $('.form_date').datetimepicker({
        language:  'zh-CN',
        weekStart: 0,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0,
        /!*      endDate:newDay*!/
    });*/
});
